package cn.edu.cug.cs.gtl.oi.ui.menu;

import cn.edu.cug.cs.gtl.oi.ui.MainApp;
import cn.edu.cug.cs.gtl.oi.ui.actions.OpenH3DFileActionListener;
import cn.edu.cug.cs.gtl.oi.ui.actions.SaveH3DFileActionListener;

import javax.swing.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

public class JMenuProject extends JMenu {
    MainApp theApp;
    JMenuItem ItemNewProject = new JMenuItem("新建工程");
    JMenuItem ItemNewDetailModule = new JMenuItem("新建精细模型");
    JMenuItem ItemOpen = new JMenuItem("打开");
    JMenuItem ItemClose = new JMenuItem("关闭");
    JMenuItem ItemSave = new JMenuItem("保存");
    JMenuItem ItemSaveAs = new JMenuItem("另存为");
    JMenu MenuImport = new JMenu("导入");
    JMenuItem ItemDXF = new JMenuItem("DXF数据文件");
    JMenuItem ItemE00 = new JMenuItem("E00数据文件");
    JMenuItem ItemSHP = new JMenuItem("SHP数据文件");
    JMenuItem ItemMIF = new JMenuItem("MIF数据文件");
    JMenuItem ItemDATAMINE = new JMenuItem("DATAMINE数据文件");
    JMenuItem Item3DS = new JMenuItem("3DS数据文件");
    JMenuItem ItemKML = new JMenuItem("KML数据文件");
    JMenuItem ItemGeo3DML = new JMenuItem("Geo3DML数据文件");
    JMenuItem ItemGeoOFF = new JMenuItem("OFF数据文件");
    JMenuItem ItemGeoGEO1 = new JMenuItem("GEO数据文件????");
    JMenuItem ItemGeoGEO2 = new JMenuItem("GEO剖面数据?????");
    JMenu MenuExport = new JMenu("导出");
    JMenuItem ItemShearPlate = new JMenuItem("剪切板");
    JMenuItem ItemBitmap = new JMenuItem("位图");
    JMenuItem ItemExDXF = new JMenuItem("DXF数据文件");
    JMenuItem ItemExSHP = new JMenuItem("SHP数据文件");
    JMenuItem ItemExMIF = new JMenuItem("MIF数据文件");
    JMenuItem ItemSelectObject = new JMenuItem("选中对象");
    JMenuItem ItemExGeo3DML = new JMenuItem("Geo3DML数据文件");
    JMenuItem ItemExOFF = new JMenuItem("OFF数据文件");
    JMenuItem ItemPrint = new JMenuItem("打印");
    JMenuItem ItemPrintPreview = new JMenuItem("打印预览");
    JMenuItem ItemPrintSetting = new JMenuItem("打印设置");
    JMenuItem ItemExit = new JMenuItem("退出");

    public JMenuProject(MainApp theApp) {
        this.theApp = theApp;
        this.setText("工程(P)");
        this.setMnemonic(KeyEvent.VK_P);
        init();
    }

    void init() {
        ItemNewProject.setAccelerator(KeyStroke.getKeyStroke('N', InputEvent.CTRL_DOWN_MASK));
        this.add(ItemNewProject);

        this.add(ItemNewDetailModule);
        this.addSeparator();

        ItemOpen.setAccelerator(KeyStroke.getKeyStroke('O', InputEvent.CTRL_DOWN_MASK));
        ItemOpen.addActionListener(new OpenH3DFileActionListener(theApp));
        this.add(ItemOpen);

        this.add(ItemClose);
        this.addSeparator();

        ItemSave.setAccelerator(KeyStroke.getKeyStroke('S', InputEvent.CTRL_DOWN_MASK));
        this.add(ItemSave);

        ItemSaveAs.addActionListener(new SaveH3DFileActionListener(theApp));
        this.add(ItemSaveAs);
        this.addSeparator();

        MenuImport.add(ItemDXF);

        MenuImport.add(ItemE00);

        MenuImport.add(ItemSHP);

        MenuImport.add(ItemMIF);

        MenuImport.add(ItemDATAMINE);

        MenuImport.add(Item3DS);

        MenuImport.add(ItemKML);

        MenuImport.add(ItemGeo3DML);

        MenuImport.add(ItemGeoOFF);

        MenuImport.add(ItemGeoGEO1);

        ItemGeoGEO2.setEnabled(false);
        MenuImport.add(ItemGeoGEO2);

        this.add(MenuImport);

        MenuExport.add(ItemShearPlate);

        MenuExport.add(ItemBitmap);

        MenuExport.add(ItemExDXF);

        MenuExport.add(ItemExSHP);

        MenuExport.add(ItemExMIF);

        ItemSelectObject.setEnabled(false);
        MenuExport.add(ItemSelectObject);

        MenuExport.add(ItemExGeo3DML);

        ItemExOFF.setEnabled(false);
        MenuExport.add(ItemExOFF);

        this.add(MenuExport);
        this.addSeparator();

        ItemPrint.setAccelerator(KeyStroke.getKeyStroke('P', InputEvent.CTRL_DOWN_MASK));
        this.add(ItemPrint);

        this.add(ItemPrintPreview);

        this.add(ItemPrintSetting);
        this.addSeparator();

        this.add(ItemExit);
    }
}
